package com.dsj.gxrd.modules.controller.people;

import com.dsj.gxrd.modules.people.domain.dto.RdUserInfoCockpit;
import com.dsj.gxrd.modules.people.domain.query.RdUserInfoQuery;
import com.dsj.gxrd.modules.people.domain.vo.CwhRepresent;
import com.dsj.gxrd.modules.people.domain.vo.RdUserInfoRepresentVo;
import com.dsj.gxrd.modules.people.domain.vo.RdUserInfoStatisticsVo;
import com.dsj.gxrd.modules.people.domain.vo.RdUserInfoVo;
import com.dsj.gxrd.modules.people.service.RdUserInfoService;
import com.ruoyi.common.core.utils.PageInfoUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author songpin566
 * @date 2023/09/21
 **/
@Api(tags = "机构人员管理")
@RestController
@RequestMapping("/people/manage")
public class RdUserInfoController extends BaseController {

    @Autowired
    private RdUserInfoService userInfoService;

    @ApiOperation(value = "查询机构人员信息", response = RdUserInfoVo.class)
    @GetMapping("/list")
    public TableDataInfo list(RdUserInfoQuery userInfoQuery) {
        PageInfoUtil<RdUserInfoVo> list = userInfoService.list(userInfoQuery);
        return getDataTableBySelfPage(list);
    }

    @ApiOperation(value = "查询机构人员信息详情")
    @GetMapping("/{userId}")
    public AjaxResult getInfo(@PathVariable Long userId) {
        RdUserInfoVo sysUser = userInfoService.selectUserById(userId);
        return AjaxResult.success(sysUser);
    }

    /**
     * 代表活跃度
     */
    @GetMapping(value = "/cockpit")
    public AjaxResult cockpit() {
        startPage();
        List<RdUserInfoCockpit>list=userInfoService.cockpit();
        return success(list);
    }

    /**
     * 代表构成
     */
    @GetMapping("/representative")
    public AjaxResult representative() {
        RdUserInfoRepresentVo list = userInfoService.representative();
        return AjaxResult.success(list);
    }

    /**
     * 乡镇级以上人大代表按部门汇总
     */
    @GetMapping("/cwh/represent")
    public AjaxResult cwhRepresent() {
        Map<String,List<CwhRepresent>> represent = userInfoService.cwhRepresent();
        return AjaxResult.success(represent);
    }

    /**
     * 中间人大代表构成
     */
    @GetMapping("/statistics")
    public AjaxResult middleRepresentative(Long deptId) {
        RdUserInfoStatisticsVo statisticsVo = userInfoService.middleRepresentative(deptId);
        return AjaxResult.success(statisticsVo);
    }


}
